<?php
/**
 * Created by PhpStorm.
 * User: MR.Z < zsh2088@gmail.com >
 * Date: 2017/9/28
 * Time: 13:25
 */
namespace Mp\Providers;

use Illuminate\Support\Facades\Route;
use Illuminate\Support\ServiceProvider;
use Smart\Models\SysModules;


class MpServiceProvider extends ServiceProvider {

	protected $routeMiddleware = [
		'mp.permission' => \Mp\Middleware\Permission::class,
	];

	protected $middlewareGroups = [
		'mp' => [
			'mp.permission' ,
		]
	];

	public function register(){
		$this->registerRouteMiddleware();
		$this->registerCommons();
		
	}

	/**
	 * Register the route middleware.
	 *
	 * @return void
	 */
	protected function registerRouteMiddleware() {
		// register route middleware.

		foreach ($this->routeMiddleware as $key => $middleware) {
			app('router')->aliasMiddleware($key, $middleware);
		}

		foreach($this->middlewareGroups as $key=> $middleware){
			app('router')->middlewareGroup($key,$middleware);
		}

	}

	protected function registerCommons(){

		$this->app->singleton('commons',function($app){
			return $app->make("Mp\\Service\\CommonService");
		});	

	}

	
}